package com.quik.web.front.service;

import java.util.Date;

import com.quik.entity.BizBillingChessRoom;
import com.quik.entity.BizBillingItem;
import com.quik.entity.BizBillingService;
import com.quik.entity.DtaProduct;

/**
 * 功能说明： 提供咨客模块的基础业务逻辑
 * 
 * @author Jenny
 * 
 */
public class ConsultBaseService {

	/**
	 * 组合BizBillingChessRoom对象
	 * 
	 * @param billingItemId
	 * @param calcMode
	 * @param staffNo
	 * @return
	 */
	public BizBillingChessRoom getBizBillingChessRoom(Integer billingItemId,
			Integer calcMode, String staffNo) {
		BizBillingChessRoom billingChessRoom = new BizBillingChessRoom();
		billingChessRoom.setBilling_item_id(billingItemId);
		billingChessRoom.setCalc_mode(calcMode);
		billingChessRoom.setCrt_user(staffNo);
		billingChessRoom.setStatus(BizBillingItem.STATUS_ORDER);
		return billingChessRoom;
	}

	/**
	 * 组合BizBillingService对象
	 * 
	 * @param billingItemId
	 * @param staffNo
	 * @return
	 */
	public BizBillingService getBizBillingService(Integer billingItemId,
			String staffNo) {
		return this.getBizBillingService(billingItemId, staffNo, null);
	}

	public BizBillingService getBizBillingService(Integer billingItemId,
			String staffNo, DtaProduct product) {
		BizBillingService billingService = new BizBillingService();
		billingService.setBilling_item_id(billingItemId);
		billingService
				.setStatus(BizBillingService.BILLING_SERVICE_STATUS_NORMAL);
		billingService.setCrt_user(staffNo);
		billingService.setCrt_date(new Date());
		billingService.setMod_date(new Date());
		billingService.setMod_user(staffNo);
		billingService.setTurn_type("lunCall");
		/*if(product!=null){
			billingService.setNum_of_hour(product.getNum_of_hour());
		}*/
		return billingService;
	}
	public static final BizBillingItem getBizBillingItem(DtaProduct product,
			String tokenNo, String roomNo, Integer qty, String staffNo) {
		BizBillingItem item = new BizBillingItem();
		item.setProduct_no(product.getProduct_no());
		item.setProduct_name(product.getProduct_name());
		item.setCrt_date(new Date());
		item.setCrt_user(staffNo);
		item.setIs_free(BizBillingItem.STATUS_NO);
		item.setIs_subtract(BizBillingItem.STATUS_NO);
		item.setStatus(BizBillingItem.BILLING_ITEM_STATUS_NORMAL);
		if ("Y".equalsIgnoreCase(product.getIf_need_worker())) {
			item.setServe_status(BizBillingItem.BILLING_ITEM_SERVE_STATUS_READY);
		} else if ("Y".equalsIgnoreCase(product.getIf_chess_room())) {
			item.setServe_status(BizBillingItem.BILLING_ITEM_SERVE_STATUS_READY);
		} else {
			item.setServe_status(BizBillingItem.BILLING_ITEM_SERVE_STATUS_END);
		}
		item.setToken_no(tokenNo);
		item.setRoom_no(roomNo);
		item.setQty(qty);
		return item;
	}

}
